#ifndef __BASE_CONFIG_H_
#define __BASE_CONFIG_H_

#include <string>
#include <fstream>
#include <map>
#ifdef TEST
#include <iostream>
#endif

#include "StringUtil.h"
#include "Singleton.h"
#include "Mutex.h"

namespace BASE{
	class CConfig:public Singleton<CConfig> {
		public:
			CConfig();

			bool loadFile(const std::string& _fileName);

			bool isModified();

			void reload();

			bool getBoolValue(const std::string & key, const bool defaultVal = false);

			int getIntValue(const std::string & key, const int defaultVal = 0);

			double getDoubleValue(const std::string & key, const double defaultVal = 0.0);

			std::string getStringValue(const std::string & key, const std::string defaultVal = "");

		private:
			void loadStream(std::ifstream & ifs);

		private:
			typedef std::map<std::string, std::string> ConfigValues;
			ConfigValues values;
			std::string fileName;
			time_t lastModifyTime;
			Mutex	mutex;
	};
}

#endif
